package com.ruoyi.project.system.controller;

import java.util.List;

import com.ruoyi.project.system.service.ISysMobileUserService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.SysGoodsParise;
import com.ruoyi.project.system.service.ISysGoodsPariseService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 二手物品点赞Controller
 * 
 * @author jjp
 * @date 2020-04-22
 */
@RestController
@RequestMapping("/system/GoodsParise")
public class SysGoodsPariseController extends BaseController
{
    @Autowired
    private ISysGoodsPariseService sysGoodsPariseService;


    /**
     * 查询二手物品点赞列表
     */
    @PreAuthorize("@ss.hasPermi('system:parise:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysGoodsParise sysGoodsParise)
    {
        startPage();
        List<SysGoodsParise> list = sysGoodsPariseService.selectSysGoodsPariseList(sysGoodsParise);
        return getDataTable(list);
    }

    /**
     * 用户查询二手物品点赞列表
     */
    @PreAuthorize("@ss.hasPermi('system:parise:list')")
    @GetMapping("/getPariseList")
    public TableDataInfo getPariseList(SysGoodsParise sysGoodsParise)
    {
        startPage();
        List<SysGoodsParise> list = sysGoodsPariseService.selecUserNameById(sysGoodsParise.getGoodsId());
        return getDataTable(list);
    }

    /**
     * 获取二手物品点赞详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:parise:query')")
    @GetMapping(value = "/{pariseId}")
    public AjaxResult getInfo(@PathVariable("pariseId") Long pariseId)
    {
        return AjaxResult.success(sysGoodsPariseService.selectSysGoodsPariseById(pariseId));
    }

    /**
     * 新增二手物品点赞
     */
    @PreAuthorize("@ss.hasPermi('system:parise:add')")
    @Log(title = "二手物品点赞", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysGoodsParise sysGoodsParise)
    {
        return toAjax(sysGoodsPariseService.insertSysGoodsParise(sysGoodsParise));
    }

    /**
     * 修改二手物品点赞
     */
    @PreAuthorize("@ss.hasPermi('system:parise:edit')")
    @Log(title = "二手物品点赞", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysGoodsParise sysGoodsParise)
    {
        return toAjax(sysGoodsPariseService.updateSysGoodsParise(sysGoodsParise));
    }

    /**
     * 删除二手物品点赞
     */
    @PreAuthorize("@ss.hasPermi('system:parise:remove')")
    @Log(title = "二手物品点赞", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pariseIds}")
    public AjaxResult remove(@PathVariable Long[] pariseIds)
    {
        return toAjax(sysGoodsPariseService.deleteSysGoodsPariseByIds(pariseIds));
    }

}
